<template>
  <div class="tip">
    <div>
      <el-checkbox v-model="checked" class="check" size="medium">
        {{$t('public.agree')}}
        <a :href="hrefgo" target="_blank">{{$t('public.userAgree')}}</a>
      </el-checkbox>
    </div>
    <el-button @click="handleAgree" type="primary" :disabled="!checked" class="ml5 btn"> {{$t('public.next')}} </el-button>
  </div>
</template>

<script>
// import { EosModel } from '@/utils/eos';
// import { authorized } from '@/utils/validate';

export default {
  data() {
    return {
      checked: true,
      hrefgo: 'https://newdex.zendesk.com/hc/en-us/articles/360012588791-User-Agreement',
    };
  },
  props: {
    embed: {
      type: Boolean,
      default: false
    },
  },
  watch: {
    '$store.state.app.language': function change(val) {
      this.handleFormatLang(val);
    }
  },
  mounted() {
    this.handleFormatLang(this.$store.state.app.language);
  },
  methods: {
    handleFormatLang(val) {
      this.hrefgo = 'https://newdex.zendesk.com/hc/en-us/articles/360012588791-User-Agreement';
      if (val === 'zh-TW') {
        this.hrefgo = 'https://newdex.zendesk.com/hc/zh-tw/articles/360012588791-%E4%BD%BF%E7%94%A8%E5%8D%94%E8%AD%B0-';
      }
      if (val === 'zh-CN') {
        this.hrefgo = 'https://newdex.zendesk.com/hc/zh-cn/articles/360012588791-%E4%BD%BF%E7%94%A8%E5%8D%8F%E8%AE%AE';
      }
    },
    handleAgree() {
      if (!this.checked) {
        return;
      }
      this.$store.dispatch('setAccountAgree', true);
      this.$emit('listenAgree', true);
    },
  }
}
</script>

<style scoped lang="scss">
.tip{
  text-align: center;
  padding: 20px 0px;

  /deep/ .el-checkbox__label{
    color: #333;
  }

  a{
    color: #278EDA;
  }

  .btn,.btn:focus{
    width: 150px;
    margin: 25px 0px 15px 0px;
    color: #278EDA;
    background: transparent;
  }

  .btn:hover{
    color: white;
    background: #278EDA;
  }
}
.theme-1B1D27{
  .tip{
    /deep/ .el-checkbox__label{
      color: white;
    }
  }
}
</style>
